Lesson 9 - Arrays and lists

Arrays allow you to store multiple values in a organized way. You can iterate (loop) over an array in order to access all of these values. Arrays require the following

Arrays are a static data structure. That means that arrays, once created, can not have their size changed. See related links for more detail on how arrays work.

array - A data structure with a fixed size which can store multiple values. All values will have the same data type

static data structure - A data structure whose size can not change after creation.

Python does not use arrays! Python uses a data structure known as a list. A list is a dynamic data structure which can store many different types of data. It can grow and shrink as needed and is much more flexible than an array. Lists, in python, can be accessed in the same way arrays can so when you need an array you will use a list instead.


exampleList = ["bob", "fred", "sally"]
for i in exampleList:
	print i

print "my favorite is ", exampleList[2]

list - A dynamic data structure which is similar to an array but does not share arrays weaknesses.

dynamic data structure - A data structure which can grow and shrink as data is added or taken away